<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>组件基础</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <book
      :books="books1"
      title="abc"
      @new-book="handleNewBook"
    />
    <book :books="books2" title="def" />
  </div>
  <script type="module">
    import './book.js'
    new Vue({
      el: '#app',
      data: {
        books1: [
          { id: '001', title: 'javascript 入门' },
          { id: '002', title: 'css 入门' },
          { id: '003', title: 'html 入门' },
        ],
        books2: [
          { id: '001', title: 'javascript 入门' },
          { id: '003', title: 'html 入门' },
        ],
      },
      methods: {
        handleNewBook(newBook) {
          console.log(newBook)
        }
      },
    })
  </script>
</body>
</html>